package data.goods;

import java.io.Serializable;

@SuppressWarnings("serial")
public class Goods implements Serializable{
	private String goodstypeID;
    private String ID;
    private int   num;
    private double cost;
    private String productionDate;
    private String scrapDate;
    private GoodsType goodstype;
  
    public Goods(String ID,int num,String productionDate,String scrapDate ){
    	goodstype=null;
    	this.goodstypeID=ID;
        this.ID=ID+productionDate+scrapDate;
    	this.num=num;
    	this.productionDate=productionDate;
    	this.scrapDate=scrapDate;
    	setGoodsType();
    	
    }
    
    public Goods(String ID,int num,String productionDate,String scrapDate,double cost ){
    	this.goodstypeID=ID;
        this.ID=ID+productionDate+scrapDate;
    	this.num=num;
    	this.productionDate=productionDate;
    	this.scrapDate=scrapDate;
    	this.cost=cost;
    	setGoodsType();
    }
 
    
	private void setGoodsType(){
    	GoodsTypeList goodstypelist=new GoodsTypeList();
    	goodstype = (GoodsType) goodstypelist.idFind(goodstypeID);
    }
	
	public String getGoodsTypeID(){
		return goodstypeID;
	}
    
    public void setID(String ID){
    	this.ID=ID;
    }
    
    public String getID(){
    	return ID;
    }
    
	public String getType(){
		return goodstype.getType();
	}
	
	
    
    public String getName(){
    	return goodstype.getName();
    }
    
    public double getPrice(){
    	return goodstype.getPrice();
    }
    
    public double getCost(){
    	return getPrice()*num;
    }
    
    public int getNum(){
    	return num;
    }
    
    public void setNum(int num){
    	this.num=num;
    }
    
    public String getProductionDate(){
    	return productionDate;
    }
    
    public String getScrapDate(){
    	return scrapDate;
    }
    
    public void setProductionDate(String date){
    	this.productionDate=date;
    }
    
    public void setScrapDate(String date){
    	this.scrapDate=date;
    }
    public void changeNum(int changeNum){
    	num=num+changeNum;
    }
    
    public String toString(){
    	return "ID: "+ID+"'scroll1 number is "+num+"\n";
    }
}
